﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Omes.Services;
using CommonControl.StyleFashin.Web.CustomerControls;

namespace FashionMural.Web
{
    public partial class Ohters : System.Web.UI.Page
    {
        private IPageService pageservice;
        private IResourceService resourceservice;
        public List<Omes.Model.Page> ChildPages { set; get; }
        public Omes.Model.Page CurrentPage { set; get; }
        protected void Page_Load(object sender, EventArgs e)
        {
            pageservice = new PageService();
            resourceservice = new ResourceService();
            var pageidstr = HttpContext.Current.Request.Params["t"];
            var pagenumberstr = HttpContext.Current.Request.Params["p"];
            var newtype = HttpContext.Current.Request.Params["n"];
            int pid = int.Parse(System.Configuration.ConfigurationManager.AppSettings["xwzx"]);
            int pageid = pid;
            int pageNumber = 1;

            if (!int.TryParse(pagenumberstr, out pageNumber))
            {
                pageNumber = 1;
            }
            var page = pageservice.GetPage(pageid);
            var controlPartName = string.Empty;
            CurrentPage = pageservice.GetPage(pageid);
            controlPartName = "ListOthersControl";
            var customControl = this.Page.LoadControl("/StyleFashin/" + controlPartName + ".ascx") as CommonControl.Web.CustomerControls.ICustomControl;
            customControl.ItemAction = "/NewDetail.aspx?n=" + newtype + "&t={0}&f=" + pageid;
            customControl.PageUrl = "/News.aspx?n=" + newtype + "&t=" + pageid + "&p={0}";
            var lscl = customControl as CommonControl.IListTextControl;
            var ls = resourceservice.GetNews(pageid, null, pageNumber, 6, 0, newtype);
            lscl.PageSize = 6;
            lscl.TotalNumber = ls.TotalCount;
            lscl.CurrentPageNumber = pageNumber;
            lscl.Links = ls.Lists;
            contentPH.Controls.Add(customControl as UserControl);

        }
    }
}